﻿using System.Web;
using BLL;
using System.Data;
using System.IO;
using System.Web.Script.Serialization;
using System.Configuration;

namespace website.CustomerMFG
{
    /// <summary>
    /// CustomerMFG 的摘要说明
    /// </summary>
    public class CustomerMFG : IHttpHandler
    {
        HttpRequest Request = null;
        HttpResponse Response = null;

        string Action = "";

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Request = context.Request;
            Response = context.Response;

            Action = Request.Params["Action"];
            // 当前用户为宏大   构造客户信息select列表
            if (Action == "getCustomerList")
            {
                context.Response.Write(getCustomerList());
            }
            // 构造报警信息列表
            else if (Action == "initAlarmInfo")
            {
                context.Response.Write(initAlarmInfo());
            }
            // 开停车记录
            else if (Action == "initKaitingcheInfo")
            {
                context.Response.Write(initKaitingcheInfo());
            }
            // 开停车记录 详细信息
            else if (Action == "initKaitingchedetailInfo")
            {
                context.Response.Write(initKaitingchedetailInfo());
            }
            //  根据 客户ID 获取设备卡号select下拉列表
            else if (Action == "getEquNoListByCustomerID")
            {
                context.Response.Write(getEquNoListByCustomerID());
            }

        }

        /// <summary>
        /// 当前用户为宏大   构造客户信息select列表
        /// </summary>
        /// <returns></returns>
        public string getCustomerList()
        {
            //string EquNo = Request["EquNo"];
            string json = CustomerMFGBLL.getCustomerList();
            return json;
        }

        /// <summary>
        /// 根据 客户ID 获取设备卡号select下拉列表
        /// </summary>
        /// <returns></returns>
        public string getEquNoListByCustomerID()
        {
            string CustomerID = Request["CustomerID"];
            string json = CustomerMFGBLL.getEquNoListByCustomerID(CustomerID);
            return json;
        }

        /// <summary>
        /// 构造报警信息列表
        /// </summary>
        /// <returns></returns>
        public string initAlarmInfo()
        {
            string CustomerID = Request["CustomerID"];
            string json = CustomerMFGBLL.initAlarmInfo(CustomerID);
            return json;
        }

        /// <summary>
        /// 开停车记录
        /// </summary>
        /// <returns></returns>
        public string initKaitingcheInfo()
        {
            string customerID = this.Request["CustomerID"];
            string taiHao = this.Request["TaiHao"];
            string type = this.Request["Type"];
            string banCi = this.Request["BanCi"];
            string startTime = this.Request["StartTime"];
            string endTime = this.Request["EndTime"];
            return CustomerMFGBLL.initKaitingcheInfo(customerID, taiHao, type, banCi, startTime, endTime);

        }

        /// <summary>
        /// 开停车记录 详细信息
        /// </summary>
        /// <returns></returns>
        public string initKaitingchedetailInfo()
        {
            string customerID = this.Request["CustomerID"];
            string taiHao = this.Request["TaiHao"];
            string type = this.Request["Type"];
            string banCi = this.Request["BanCi"];
            string startTime = this.Request["StartTime"];
            string endTime = this.Request["EndTime"];
            return CustomerMFGBLL.initKaitingchedetailInfo(customerID, taiHao, type, banCi, startTime, endTime);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}